/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PreferencesView.java
 *
 * Created on 18/05/2011, 17:18:44
 */

package presentation;

import javax.swing.ImageIcon;
import java.awt.Graphics;
import java.awt.BorderLayout;
/**
 *
 * @author Andreu Marimon
 */
public class HelpView extends GraficConf {
    PresentationController _pCntrl;
    /** Creates new form PreferencesView */
    public HelpView(PresentationController pCntrl) {
	super(pCntrl);
	_pCntrl = pCntrl;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        backButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();

        setMaximumSize(new java.awt.Dimension(800, 600));
        setMinimumSize(new java.awt.Dimension(800, 600));

        backButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/presentation/imatges/backbutton.jpg"))); // NOI18N
        backButton.setBorderPainted(false);
        backButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/presentation/imatges/pressedbackbutton.jpg"))); // NOI18N
        backButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/presentation/imatges/hoverbackbutton.jpg"))); // NOI18N
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 593, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 578, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addComponent(backButton, javax.swing.GroupLayout.PREFERRED_SIZE, 179, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(530, 530, 530)
                        .addComponent(backButton, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
		_pCntrl.goToEdit();
    }//GEN-LAST:event_backButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton backButton;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

    @Override
    public void paintComponent(Graphics g) {
		super.paintComponent(g);
		this.setOpaque(true);
		ImageIcon background;
		String slash = System.getProperty("file.separator");
		String jarPath = System.getProperty("java.class.path");
		int lastDot = jarPath.lastIndexOf(";");
		String aux = jarPath;
		if (lastDot != -1) {
			aux = jarPath.substring(0, lastDot);
		}
		int lastSlash = aux.lastIndexOf(slash);
		String path = aux.substring(0,lastSlash+1);
		background = new ImageIcon(path+"imatges"+slash+"backgroundpreferences.jpg")  ;
		g.drawImage(background.getImage(), 0, 0, 800, 600, null );
    }
}
